package com.client.koshercook.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
import com.google.gwt.user.client.ui.RootPanel;
/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Client implements EntryPoint{
	
	//main panel
	private DockPanel panel = new DockPanel();
	
	//sub-panels
	private RecipesTable recipesTable;
	private UserIngredientsTable userIngsTable;
	private LoginPanel loginPanel;
	private TopRated topRated;
	private EdgesPanel generalInfoPanel;
	private BottomPanel bottomPanel;
	
	
	static public MultiWordSuggestOracle oracle = new MultiWordSuggestOracle();
	static public Model model;
	static public HTML pageText = new HTML("1 עמוד");
	static public HTML uesrNick = new HTML("שם משתמש כאן");
		
	/** The entry point method. */
	public void onModuleLoad() {
		//creating the model
		model = new Model();
		//getting needed model elements
		recipesTable = model.recipesTable;
		userIngsTable = model.userIngsTable;
		loginPanel = model.loginPanel;
		topRated = model.topRated;
		generalInfoPanel = model.generalInfoPanel;
		bottomPanel = model.bottomPanel;

		if(Window.getClientWidth() <= 800 && Window.getClientHeight() <= 600){
			Client.model.setSmallScreen();
		}
		
		userIngsTable.addStyleName("userIngsTable");
		panel.setWidth("100%");
		panel.setHeight("100%");
		panel.addStyleName("mainPanel");

		panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
		panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
	    panel.add(loginPanel, DockPanel.NORTH);
	    panel.add(bottomPanel, DockPanel.SOUTH);
	    
	    panel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
	    panel.add(generalInfoPanel, DockPanel.SOUTH);
	    panel.setCellHorizontalAlignment(generalInfoPanel, HasHorizontalAlignment.ALIGN_CENTER);
	    
		panel.add(userIngsTable, DockPanel.EAST);
		panel.add(recipesTable, DockPanel.EAST);
		panel.add(topRated, DockPanel.WEST);
		
		RootPanel.get("RecipesList").add(panel);
    }
}